import Cookies from 'js-cookie'

const TokenKey: string = import.meta.env.VITE_APP_TOKEN_KEY as string
const OpenTokenKey: string = import.meta.env.VITE_APP_OPEN_TOKEN_KEY as string

export function getToken(): string | undefined {
  return Cookies.get(TokenKey)
}

export function setToken(token: string): void {
  Cookies.set(TokenKey, token)
}

export function removeToken(): void {
  Cookies.remove(TokenKey)
}

export function getOpenToken(): string | undefined {
  return Cookies.get(OpenTokenKey)
}

export function setOpenToken(token: string): void {
  Cookies.set(OpenTokenKey, token)
}

export function removeOpenToken(): void {
  Cookies.remove(OpenTokenKey)
}

export function getTokenHeader() {
  return { [import.meta.env.VITE_APP_TOKEN_KEY as string]: getToken() }
}
